import request from "./request";

//获取分类管理配置列表
const classifyList = (pageNumber = 1, pageSize = 10, categoryLevel = 1, parentId = 0) => {
  return request.get('/api/categories', {
    params: {
      pageNumber,
      pageSize,
      categoryLevel,
      parentId
    }
  });
};
// 新增分类管理信息
const classifyInsert = (body) => {
  return request.post('/api/categories', body);
};

// 修改分类管理信息
const classifyUpdate = (body) => {
  return request.put('/api/categories', body);
};

// 删除分类管理信息
const classifyRemove = (ids = []) => {
  return request('/api/categories', {
    method: 'DELETE',
    data: {
      ids
    }
  });
};

////////////////////////////////////

// 获取商品管理列表
const goodsList = (pageNumber = 1, pageSize = 10) => {
  return request.get('/api/goods/list', {
    params: {
      pageNumber,
      pageSize
    }
  });
};
//上架
const putShop = (ids = []) => {
  return request.put('/api/goods/status/0', {
    ids
  });
};
//下架
const downShop = (ids = []) => {
  return request.put('/api/goods/status/1', {
    ids
  });
};
//修改商品
const modifyList = (id = 0) => {
  return request.get(`/api/goods/${id}`);
};
//修改商品
const addList = (body) => {
  return request.put(`/api/goods`, body);
}
//新增
const newList = (body) => {
  return request.post('/api/goods', body);
};

/////////////////////////////

// 获取会员管理列表
const memberList = (pageNumber = 1, pageSize = 10) => {
  return request.get('/api/users', {
    params: {
      pageNumber,
      pageSize
    }
  });
};
//解禁
const disable = (ids = []) => {
  return request.put('/api/users/0', {
    ids
  });
};
//禁用
const unban = (ids = []) => {
  return request.put('/api/users/1', {
    ids
  });
};
//////////////////////////////////

// 获取订单管理列表
const orderList = (pageNumber = 1, pageSize = 10, orderNo, orderStatus
) => {
  return request.get('/api/orders', {
    params: {
      pageNumber,
      pageSize,
      orderNo,
      orderStatus
    }
  });
};

// 关闭订单信息
const orderDown = (ids = []) => {
  return request('/api/orders/close', {
    method: 'PUT',
    data: {
      ids
    }
  });
}

// 出库成功
const checkOut = (ids = []) => {
  return request('/api/orders/checkOut', {
    method: 'PUT',
    data: {
      ids
    }
  });
}

// 出库失败
const checkDone = (ids = []) => {
  return request('/api/orders/checkDone', {
    method: 'PUT',
    data: {
      ids
    }
  });
}
// 获取订单详情数据
const ordersId = (id) => {
  return request.get(`/api/orders/${id}`)
}

export default {
  classifyList,
  classifyInsert,
  classifyUpdate,
  classifyRemove,
  goodsList,
  memberList,
  orderList,
  putShop,
  downShop,
  modifyList,
  addList,
  disable,
  unban,
  newList,
  orderDown,
  checkOut,
  checkDone,
  ordersId
}
